#!/usr/bin/perl -w
use strict;
use File::Copy;
use File::Path;
use File::Basename;

sub copyIncludes( $ );

# the purpose of this perl program is to copy boost include file to local directory
copyIncludes("Output-Build.txt");

sub copyIncludes( $ )
{
	my $count = 0;
	open(my $fh, '<', $_[0]) or die "Cannot open $_[0]: $!";
	while(<$fh>)
	{
		if(/(D:\\Program Files \(2\)\\boost_1_43_0\\([a-zA-Z0-9 \/_.]+))/)
		{
			my $src = $1;
			my $dst = "boost/include/" . $2;
			my ($name, $path) = fileparse($dst);
			if(not -e $dst)
			{
				if(not -d $path)
				{
					mkpath($path) or die "Cannot mkpath $path: $!";
				}
				die "$src did not exist" if not -e $src;
				copy($src, $dst) or die "Cannot copy $src to $dst: $!";
				$count++;
				print "Succeeded to copy $dst" . "\n";
			}
		}
	}
	close($fh);
	print "$count files copied\n";
}
